package com.squirrel.michale;

/**
 * @author guanhao 观浩
 * @version 1.0.0.0
 * @createTime 2023/2/27 8:28 PM
 * @company Michale Squirrel
 * @link
 * @description
 */
public class LeetCode0781 {

    public int numRabbits(int[] answers) {
        if(answers.length==0) return 0;
        if(answers.length==1) return answers[0]+1;

        int[] map = new int[1000];

        for (int answer : answers) {
            map[answer]++;
        }
        int res = map[0];
        for (int i = 1; i < map.length; i++) {
            if(map[i]==0) continue;
            int round = (int)Math.ceil((double)map[i]/(i+1));
            res += round*(i+1);
        }

        return res;
    }
}
